package com.blog.backend.gateWayController;


import com.blog.backend.domain.BlogPerson;
import com.blog.backend.domain.BlogPersonWithBLOBs;
import com.blog.backend.mapper.SysSettingMapper;
import com.blog.backend.req.AssessReq;
import com.blog.backend.resp.BlogAssessResp;
import com.blog.backend.resp.PersonResp;
import com.blog.backend.service.SysSettingService;
import com.blog.backend.utils.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/setting")
public class DoorSettingController {

    @Resource
    private SysSettingService sysSettingService;


    @GetMapping("/getEmail")
    public Result<String> getEmail(){
       String email= sysSettingService.getEmail();
       return Result.success(email);
    }

    @GetMapping("/getAdvertisementUrl")
    public Result<String> getAdvertisementUrl(){
        String url=sysSettingService.getAdvertisementUrl();
        return Result.success(url);
    }


    @GetMapping("/getPersonInfo")
    public Result<BlogPersonWithBLOBs> getPersonInfo(){
        BlogPersonWithBLOBs resp=sysSettingService.getPersonInfo();
        return Result.success(resp);
    }

    @GetMapping("/getPersonSimpleInfo")
    public Result<BlogPerson> getPersonSimpleInfo(){
        BlogPerson blogPerson=  sysSettingService.getPersonSimpleInfo();
        return Result.success(blogPerson);
    }


    @GetMapping("/addBrowseNum")
    @ApiOperation("增加浏览数")
    public Result<Boolean> addBrowseNum(@RequestParam("articleId") String articleId, @RequestParam("type") Integer type){
        Boolean result=sysSettingService.addBrowseNum(articleId,type);
        return Result.success(result);
    }

    @GetMapping("/addLikeNum")
    public Result<Boolean> addLikeNum(@RequestParam("articleId") String articleId, @RequestParam("type") Integer type){
        Boolean result=sysSettingService.addLikeNum(articleId,type);
        return Result.success(result);
    }

    @PostMapping("/addComment")
    public Result<Boolean> addComment(@RequestBody AssessReq req){
        Boolean result=sysSettingService.addComment(req);
        return Result.success(result);
    }

    @GetMapping("/getArticleAssess")
    public Result<List<BlogAssessResp>> getArticleAssess(@RequestParam String articleId){
        List<BlogAssessResp> list=sysSettingService.getArticleAssess(articleId);
        return Result.success(list);
    }

}
